import  requests
import  re
import pymysql
import threading

db = pymysql.connect(
    host = 'localhost',
     port= 3306,
     user ='root',
     passwd= 'jingfei',
     db = '表格',
     charset = 'UTF8'
)

cursor= db.cursor()

def getImagesList(page):
     response =  requests.get('http://www.doutula.com/article/list/?page='+str(page))
     html = response.text
     reg = re.compile(r'</div>.*?data-original="(.*?)".*?alt="(.*?)".*?</div>',re.S)
     images = re.findall(reg,html)
     for i in images:
          cursor.execute("insert into image(`name`,`imageurl`)values('{}','{}')".format(i[1],i[0]))
          db.commit()
          print(i[1])

def main():
     for m in range(540):
          getImagesList(m)

main()


db.close()